package p270jp.pxv.android.license.presentation.activity;

import android.content.ComponentCallbacks;
import android.content.Context;
import android.os.Bundle;
import android.support.p024v4.media.C0261e;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.ComponentActivity;
import androidx.compose.p026ui.platform.C0536v1;
import androidx.lifecycle.ViewModelStore;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.google.android.material.appbar.MaterialToolbar;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import p023an.Intrinsics;
import p045be.View$OnClickListenerC1058b0;
import p047bg.C1124a;
import p054bn.AbstractC1136i;
import p054bn.DebugMetadata;
import p060c2.Chain;
import p062c4.ViewBindings;
import p064c6.Preconditions;
import p081cn.progressionUtil;
import p089d.C2427i;
import p185gj.ActivityLicenseBinding;
import p185gj.ListItemLicenseArtifactBinding;
import p189gn.AbstractC3435a;
import p189gn.AbstractC3450p;
import p216hn.Lambda;
import p216hn.Reflection;
import p270jp.pxv.android.R;
import p270jp.pxv.android.license.model.License;
import p270jp.pxv.android.license.model.LicenseArtifact;
import p289kj.AbstractActivityC4542b;
import p294ko.ViewModelOwner;
import p310lc.C4621b;
import p317lj.C4703d;
import p317lj.LicenseActionCreator;
import p317lj.LicenseEvent;
import p317lj.LicenseState;
import p317lj.LicenseStore;
import p325m0.MutabilityOwnership;
import p337mc.GroupieAdapter;
import p350mp.Timber;
import p364nc.BindableItem;
import p370ni.InfoType;
import p501sn.CoroutineScope;
import p578vn.AbstractC6861n;
import p578vn.AbstractC6866q;
import p578vn.FlowCollector;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;
import p603wm.Unit;
import p625xi.LegacyNavigation;
import p629xm.IteratorsJVM;
import p629xm._Collections;
import p681zm.Continuation;

/* compiled from: LicenseActivity.kt */
/* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity */
/* loaded from: classes2.dex */
public final class LicenseActivity extends AbstractActivityC4542b {

    /* renamed from: A */
    public static final /* synthetic */ int f19105A;

    /* renamed from: v */
    public final AbstractC6949c f19106v = C4621b.m3851a(this, C4257b.f19115c);

    /* renamed from: w */
    public final GroupieAdapter f19107w = new GroupieAdapter();

    /* renamed from: x */
    public final AbstractC6949c f19108x = Preconditions.m9802P(3, new C4264g(this, null, null, new C4263f(this), null));

    /* renamed from: y */
    public final AbstractC6949c f19109y = Preconditions.m9802P(3, new C4266i(this, null, null, new C4265h(this), null));

    /* renamed from: z */
    public final AbstractC6949c f19110z = Preconditions.m9802P(1, new C4262e(this, null, null));

    /* compiled from: LicenseActivity.kt */
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$a */
    /* loaded from: classes2.dex */
    public static final class C4256a extends BindableItem<ListItemLicenseArtifactBinding> {

        /* renamed from: g */
        public static final /* synthetic */ int f19111g;

        /* renamed from: d */
        public final LicenseArtifact f19112d;

        /* renamed from: e */
        public final Context f19113e;

        /* renamed from: f */
        public final C4703d f19114f;

        public C4256a(LicenseArtifact licenseArtifact, Context context, C4703d dVar) {
            MutabilityOwnership.m3745m(licenseArtifact, "artifact");
            MutabilityOwnership.m3745m(dVar, "actionCreator");
            this.f19112d = licenseArtifact;
            this.f19113e = context;
            this.f19114f = dVar;
        }

        @Override // p337mc.Item
        /* renamed from: b */
        public int mo3603b() {
            return R.layout.list_item_license_artifact;
        }

        @Override // p364nc.BindableItem
        /* renamed from: e */
        public void mo3420e(ListItemLicenseArtifactBinding bVar, int i) {
            String str;
            ListItemLicenseArtifactBinding bVar2 = bVar;
            MutabilityOwnership.m3745m(bVar2, "viewBinding");
            bVar2.f15664e.setText(this.f19112d.getName());
            List<String> copyRights = this.f19112d.getCopyRights();
            if (copyRights == null) {
                str = null;
            } else {
                str = MutabilityOwnership.m3739s("Copyright : ", _Collections.m692V(copyRights, ", ", null, null, 0, null, null, 62));
            }
            bVar2.f15663d.setText(str);
            bVar2.f15662c.setText(this.f19112d.getArtifact());
            bVar2.f15661b.removeAllViews();
            for (License license : this.f19112d.getLicenses()) {
                View inflate = LayoutInflater.from(this.f19113e).inflate(R.layout.view_license, (ViewGroup) null, false);
                int i2 = R.id.text_name;
                TextView textView = (TextView) ViewBindings.m9835b(inflate, R.id.text_name);
                if (textView != null) {
                    i2 = R.id.text_url;
                    TextView textView2 = (TextView) ViewBindings.m9835b(inflate, R.id.text_url);
                    if (textView2 != null) {
                        textView.setText(MutabilityOwnership.m3739s("- Under ", license.getName()));
                        textView2.setText(license.getUrl());
                        textView2.setOnClickListener(new View$OnClickListenerC1058b0(this, license, 1));
                        bVar2.f15661b.addView((LinearLayout) inflate);
                    }
                }
                throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
            }
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof C4256a)) {
                return false;
            }
            C4256a aVar = (C4256a) obj;
            return MutabilityOwnership.m3749h(this.f19112d, aVar.f19112d) && MutabilityOwnership.m3749h(this.f19113e, aVar.f19113e) && MutabilityOwnership.m3749h(this.f19114f, aVar.f19114f);
        }

        @Override // p364nc.BindableItem
        /* renamed from: f */
        public ListItemLicenseArtifactBinding mo3419f(View view) {
            MutabilityOwnership.m3745m(view, "view");
            int i = R.id.licenses;
            LinearLayout linearLayout = (LinearLayout) ViewBindings.m9835b(view, R.id.licenses);
            if (linearLayout != null) {
                i = R.id.text_artifact;
                TextView textView = (TextView) ViewBindings.m9835b(view, R.id.text_artifact);
                if (textView != null) {
                    i = R.id.text_copy_right;
                    TextView textView2 = (TextView) ViewBindings.m9835b(view, R.id.text_copy_right);
                    if (textView2 != null) {
                        i = R.id.text_name;
                        TextView textView3 = (TextView) ViewBindings.m9835b(view, R.id.text_name);
                        if (textView3 != null) {
                            return new ListItemLicenseArtifactBinding((LinearLayout) view, linearLayout, textView, textView2, textView3);
                        }
                    }
                }
            }
            throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
        }

        public int hashCode() {
            int hashCode = this.f19113e.hashCode();
            return this.f19114f.hashCode() + ((hashCode + (this.f19112d.hashCode() * 31)) * 31);
        }

        public String toString() {
            StringBuilder c = C0261e.m12042c("LicenseArtifactItem(artifact=");
            c.append(this.f19112d);
            c.append(", context=");
            c.append(this.f19113e);
            c.append(", actionCreator=");
            c.append(this.f19114f);
            c.append(')');
            return c.toString();
        }
    }

    /* compiled from: LicenseActivity.kt */
    @DebugMetadata(m10153c = "jp.pxv.android.license.presentation.activity.LicenseActivity$onCreate$1", m10152f = "LicenseActivity.kt", m10151l = {159}, m10150m = "invokeSuspend")
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$c */
    /* loaded from: classes2.dex */
    public static final class C4258c extends AbstractC1136i implements AbstractC3450p<CoroutineScope, Continuation<? super Unit>, Object> {

        /* renamed from: a */
        public int f19116a;

        /* compiled from: Collect.kt */
        /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$c$a */
        /* loaded from: classes2.dex */
        public static final class C4259a implements FlowCollector<LicenseState> {

            /* renamed from: a */
            public final /* synthetic */ LicenseActivity f19118a;

            public C4259a(LicenseActivity licenseActivity) {
                this.f19118a = licenseActivity;
            }

            @Override // p578vn.FlowCollector
            /* renamed from: a */
            public Object mo924a(LicenseState fVar, Continuation<? super Unit> dVar) {
                LicenseState fVar2 = fVar;
                if (fVar2 instanceof LicenseState.C4707c) {
                    LicenseActivity licenseActivity = this.f19118a;
                    int i = LicenseActivity.f19105A;
                    licenseActivity.m4589S0().f15657b.m4595d(InfoType.LOADING, null);
                } else if (fVar2 instanceof LicenseState.C4706b) {
                    LicenseActivity licenseActivity2 = this.f19118a;
                    int i2 = LicenseActivity.f19105A;
                    licenseActivity2.m4589S0().f15657b.m4598a();
                    LicenseActivity licenseActivity3 = this.f19118a;
                    List<LicenseArtifact> list = ((LicenseState.C4706b) fVar2).f22579a;
                    Objects.requireNonNull(licenseActivity3);
                    ArrayList arrayList = new ArrayList(IteratorsJVM.m703K(list, 10));
                    for (LicenseArtifact licenseArtifact : list) {
                        arrayList.add(new C4256a(licenseArtifact, licenseActivity3, (C4703d) licenseActivity3.f19108x.getValue()));
                    }
                    licenseActivity3.f19107w.m3604t(arrayList);
                } else if (fVar2 instanceof LicenseState.C4705a) {
                    LicenseActivity licenseActivity4 = this.f19118a;
                    int i3 = LicenseActivity.f19105A;
                    licenseActivity4.m4589S0().f15657b.m4598a();
                    Toast.makeText(this.f19118a, (int) R.string.error_default_title, 1).show();
                    Timber.f23100a.mo3524e(((LicenseState.C4705a) fVar2).f22578a);
                }
                return Unit.f29503a;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4258c(Continuation<? super C4258c> dVar) {
            super(2, dVar);
            LicenseActivity.this = r1;
        }

        @Override // p054bn.ContinuationImpl
        public final Continuation<Unit> create(Object obj, Continuation<?> dVar) {
            return new C4258c(dVar);
        }

        @Override // p189gn.AbstractC3450p
        public Object invoke(CoroutineScope d0Var, Continuation<? super Unit> dVar) {
            return new C4258c(dVar).invokeSuspend(Unit.f29503a);
        }

        @Override // p054bn.ContinuationImpl
        public final Object invokeSuspend(Object obj) {
            Intrinsics aVar = Intrinsics.COROUTINE_SUSPENDED;
            int i = this.f19116a;
            if (i == 0) {
                Chain.m9951I(obj);
                AbstractC6866q<LicenseState> qVar = ((LicenseStore) LicenseActivity.this.f19109y.getValue()).f22583e;
                C4259a aVar2 = new C4259a(LicenseActivity.this);
                this.f19116a = 1;
                if (qVar.mo1092c(aVar2, this) == aVar) {
                    return aVar;
                }
            } else if (i == 1) {
                Chain.m9951I(obj);
            } else {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            return Unit.f29503a;
        }
    }

    /* compiled from: LicenseActivity.kt */
    @DebugMetadata(m10153c = "jp.pxv.android.license.presentation.activity.LicenseActivity$onCreate$2", m10152f = "LicenseActivity.kt", m10151l = {159}, m10150m = "invokeSuspend")
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$d */
    /* loaded from: classes2.dex */
    public static final class C4260d extends AbstractC1136i implements AbstractC3450p<CoroutineScope, Continuation<? super Unit>, Object> {

        /* renamed from: a */
        public int f19119a;

        /* compiled from: Collect.kt */
        /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$d$a */
        /* loaded from: classes2.dex */
        public static final class C4261a implements FlowCollector<LicenseEvent> {

            /* renamed from: a */
            public final /* synthetic */ LicenseActivity f19121a;

            public C4261a(LicenseActivity licenseActivity) {
                this.f19121a = licenseActivity;
            }

            @Override // p578vn.FlowCollector
            /* renamed from: a */
            public Object mo924a(LicenseEvent eVar, Continuation<? super Unit> dVar) {
                LicenseEvent eVar2 = eVar;
                if (eVar2 instanceof LicenseEvent.C4704a) {
                    LicenseActivity licenseActivity = this.f19121a;
                    ((LegacyNavigation) licenseActivity.f19110z.getValue()).mo44g(licenseActivity, ((LicenseEvent.C4704a) eVar2).f22577a);
                }
                return Unit.f29503a;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4260d(Continuation<? super C4260d> dVar) {
            super(2, dVar);
            LicenseActivity.this = r1;
        }

        @Override // p054bn.ContinuationImpl
        public final Continuation<Unit> create(Object obj, Continuation<?> dVar) {
            return new C4260d(dVar);
        }

        @Override // p189gn.AbstractC3450p
        public Object invoke(CoroutineScope d0Var, Continuation<? super Unit> dVar) {
            return new C4260d(dVar).invokeSuspend(Unit.f29503a);
        }

        @Override // p054bn.ContinuationImpl
        public final Object invokeSuspend(Object obj) {
            Intrinsics aVar = Intrinsics.COROUTINE_SUSPENDED;
            int i = this.f19119a;
            if (i == 0) {
                Chain.m9951I(obj);
                AbstractC6861n<LicenseEvent> nVar = ((LicenseStore) LicenseActivity.this.f19109y.getValue()).f22584f;
                C4261a aVar2 = new C4261a(LicenseActivity.this);
                this.f19119a = 1;
                if (nVar.mo1092c(aVar2, this) == aVar) {
                    return aVar;
                }
            } else if (i == 1) {
                Chain.m9951I(obj);
            } else {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            return Unit.f29503a;
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$e */
    /* loaded from: classes2.dex */
    public static final class C4262e extends Lambda implements AbstractC3435a<LegacyNavigation> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f19122a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4262e(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f19122a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [java.lang.Object, xi.a] */
        @Override // p189gn.AbstractC3435a
        public final LegacyNavigation invoke() {
            return C1124a.m10173s(this.f19122a).f24118a.m920a().m621a(Reflection.m5499a(LegacyNavigation.class), null, null);
        }
    }

    /* compiled from: ActivityExt.kt */
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$f */
    /* loaded from: classes2.dex */
    public static final class C4263f extends Lambda implements AbstractC3435a<ViewModelOwner> {

        /* renamed from: a */
        public final /* synthetic */ ComponentActivity f19123a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4263f(ComponentActivity componentActivity) {
            super(0);
            this.f19123a = componentActivity;
        }

        @Override // p189gn.AbstractC3435a
        public ViewModelOwner invoke() {
            ComponentActivity componentActivity = this.f19123a;
            MutabilityOwnership.m3745m(componentActivity, "storeOwner");
            ViewModelStore viewModelStore = componentActivity.getViewModelStore();
            MutabilityOwnership.m3746l(viewModelStore, "storeOwner.viewModelStore");
            return new ViewModelOwner(viewModelStore, componentActivity);
        }
    }

    /* compiled from: ActivityExt.kt */
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$g */
    /* loaded from: classes2.dex */
    public static final class C4264g extends Lambda implements AbstractC3435a<C4703d> {

        /* renamed from: a */
        public final /* synthetic */ ComponentActivity f19124a;

        /* renamed from: b */
        public final /* synthetic */ AbstractC3435a f19125b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4264g(ComponentActivity componentActivity, Qualifier aVar, AbstractC3435a aVar2, AbstractC3435a aVar3, AbstractC3435a aVar4) {
            super(0);
            this.f19124a = componentActivity;
            this.f19125b = aVar3;
        }

        /* JADX WARN: Type inference failed for: r0v1, types: [androidx.lifecycle.j0, lj.d] */
        @Override // p189gn.AbstractC3435a
        public C4703d invoke() {
            return progressionUtil.m9685e(this.f19124a, null, null, this.f19125b, Reflection.m5499a(C4703d.class), null);
        }
    }

    /* compiled from: ActivityExt.kt */
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$h */
    /* loaded from: classes2.dex */
    public static final class C4265h extends Lambda implements AbstractC3435a<ViewModelOwner> {

        /* renamed from: a */
        public final /* synthetic */ ComponentActivity f19126a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4265h(ComponentActivity componentActivity) {
            super(0);
            this.f19126a = componentActivity;
        }

        @Override // p189gn.AbstractC3435a
        public ViewModelOwner invoke() {
            ComponentActivity componentActivity = this.f19126a;
            MutabilityOwnership.m3745m(componentActivity, "storeOwner");
            ViewModelStore viewModelStore = componentActivity.getViewModelStore();
            MutabilityOwnership.m3746l(viewModelStore, "storeOwner.viewModelStore");
            return new ViewModelOwner(viewModelStore, componentActivity);
        }
    }

    /* compiled from: ActivityExt.kt */
    /* renamed from: jp.pxv.android.license.presentation.activity.LicenseActivity$i */
    /* loaded from: classes2.dex */
    public static final class C4266i extends Lambda implements AbstractC3435a<LicenseStore> {

        /* renamed from: a */
        public final /* synthetic */ ComponentActivity f19127a;

        /* renamed from: b */
        public final /* synthetic */ AbstractC3435a f19128b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4266i(ComponentActivity componentActivity, Qualifier aVar, AbstractC3435a aVar2, AbstractC3435a aVar3, AbstractC3435a aVar4) {
            super(0);
            this.f19127a = componentActivity;
            this.f19128b = aVar3;
        }

        /* JADX WARN: Type inference failed for: r0v1, types: [androidx.lifecycle.j0, lj.g] */
        @Override // p189gn.AbstractC3435a
        public LicenseStore invoke() {
            return progressionUtil.m9685e(this.f19127a, null, null, this.f19128b, Reflection.m5499a(LicenseStore.class), null);
        }
    }

    public LicenseActivity() {
        super(R.layout.activity_license);
    }

    /* renamed from: S0 */
    public final ActivityLicenseBinding m4589S0() {
        return (ActivityLicenseBinding) this.f19106v.getValue();
    }

    @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        MaterialToolbar materialToolbar = m4589S0().f15659d;
        MutabilityOwnership.m3746l(materialToolbar, "binding.toolBar");
        C0536v1.m11537h(this, materialToolbar, R.string.copy_right);
        m4589S0().f15658c.setLayoutManager(new LinearLayoutManager(1, false));
        m4589S0().f15658c.setAdapter(this.f19107w);
        C2427i.m7689s(this).m11052d(new C4258c(null));
        C2427i.m7689s(this).m11052d(new C4260d(null));
        C4703d dVar = (C4703d) this.f19108x.getValue();
        Objects.requireNonNull(dVar);
        C1124a.m10167y(Preconditions.m9807K(dVar), null, 0, new LicenseActionCreator(dVar, null), 3, null);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        MutabilityOwnership.m3745m(menuItem, "item");
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        this.f940i.m12030b();
        return true;
    }
}
